package com.ims.core.doc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ims.common.annotation.Log;
import com.ims.common.core.controller.BaseController;
import com.ims.common.core.domain.AjaxResult;
import com.ims.common.enums.BusinessType;
import com.ims.core.doc.domain.TInNon1002;
import com.ims.core.doc.service.ITInNon1002Service;
import com.ims.common.utils.poi.ExcelUtil;
import com.ims.common.core.page.TableDataInfo;

/**
 * 火车票Controller
 *
 * @author IMS
 * @date 2024-11-20
 */
@RestController
@RequestMapping("/doc/huochepiao")
public class TInNon1002Controller extends BaseController
{
    @Autowired
    private ITInNon1002Service tInNon1002Service;

    /**
     * 查询火车票列表
     */
    @PreAuthorize("@ss.hasPermi('doc:huochepiao:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInNon1002 tInNon1002)
    {
        startPage();
        List<TInNon1002> list = tInNon1002Service.selectTInNon1002List(tInNon1002);
        return getDataTable(list);
    }

    /**
     * 导出火车票列表
     */
    @PreAuthorize("@ss.hasPermi('doc:huochepiao:export')")
    @Log(title = "火车票", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInNon1002 tInNon1002)
    {
        List<TInNon1002> list = tInNon1002Service.selectTInNon1002List(tInNon1002);
        ExcelUtil<TInNon1002> util = new ExcelUtil<TInNon1002>(TInNon1002.class);
        util.exportExcel(response, list, "火车票数据");
    }

    /**
     * 获取火车票详细信息
     */
    @PreAuthorize("@ss.hasPermi('doc:huochepiao:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tInNon1002Service.selectTInNon1002ById(id));
    }

    /**
     * 新增火车票
     */
    @PreAuthorize("@ss.hasPermi('doc:huochepiao:add')")
    @Log(title = "火车票", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInNon1002 tInNon1002)
    {
        return toAjax(tInNon1002Service.insertTInNon1002(tInNon1002));
    }

    /**
     * 修改火车票
     */
    @PreAuthorize("@ss.hasPermi('doc:huochepiao:edit')")
    @Log(title = "火车票", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInNon1002 tInNon1002)
    {
        return toAjax(tInNon1002Service.updateTInNon1002(tInNon1002));
    }

    /**
     * 删除火车票
     */
    @PreAuthorize("@ss.hasPermi('doc:huochepiao:remove')")
    @Log(title = "火车票", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tInNon1002Service.deleteTInNon1002ByIds(ids));
    }
}
